#include "StdAfx.h"


namespace DLNLib
{
	DayRecord::DayRecord( const COleDateTime& _time,const CString& _USN )
		:time(_time)
		,USN(_USN)
	{

	}
	DayRecord::~DayRecord(void)
	{
	}

	const DayRecord& DayRecord::operator=( const DayRecord& rhs )
	{
		time = rhs.time;
		USN  = rhs.USN;
		for(size_t i=0;i<24;i++)
			hour[i] = rhs.hour[i];
		return *this;
	}

	CString DayRecord::GetDayRecord()
	{
		CString strRet;
		CString strValue;
		
		strRet.Format("%s%02d%02d%02d",USN,time.GetYear()-1911,time.GetMonth(),time.GetDay());
		
		
		
		for(int i=0;i<24;i++)
		{
			if(hour[i].value==0)
				strRet += "      ";
			else
			{
				strValue.Format("%6.2f",hour[i].value);
				strRet += strValue;
			}
		}
		
		return strRet;
	}

	bool DayRecord::Append( const Data& rhs )
	{
		ASSERT( rhs.time.GetYear() == time.GetYear() &&
			    rhs.time.GetMonth()== time.GetMonth()&&
				rhs.time.GetDay()  == time.GetDay());
		if(rhs.time.GetMinute()==0)
		{
			hour[rhs.time.GetHour()] = rhs;
			return true;
		}
		return false;
	}
}